﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using BlogEngine.Core;

public partial class admin_UploadAttachments : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}

	protected void uploadButton_Click(object sender, EventArgs e)
	{
		if (uploadAttachment.HasFile)
		{
			string location = "/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + uploadAttachment.FileName;
			string path = BlogSettings.Instance.AttachmentLocation + location;

			Attachment attachment = new Attachment();
			attachment.Title = uploadTitle.Text;
			attachment.Excerpt = uploadDescription.Text;
			attachment.PermaLink = new Uri(path, UriKind.Relative);
			attachment.Save();

			uploadAttachment.SaveAs("~" + path);
		}
	}
}
